package tests.com.datasentinel.utils;

import java.util.Random;

import junit.framework.Assert;

import org.junit.Test;

import com.datasentinel.util.HashUtils;

public class HashUtils_Test
{

	@Test
	public void testStringToString()
	{
		String input = "2010016837546695";
		System.out.println("String output: " + HashUtils.getStringHashedToString(input));
	}
	
	@Test
	public void testChecksumStability()
	{
		Random random = new Random();
		
		long inputValue = random.nextLong(); 
			
		long hash = HashUtils.getLongHashedToLong(inputValue);
		System.out.println("input=" + inputValue + "; hash = " + hash);
		
		for(int i = 0; i < 256; ++i)
		{
			long hashOther= HashUtils.getLongHashedToLong(inputValue);
			Assert.assertEquals(hash, hashOther);
		}
	}

	@Test
	public void testChecksumOutput()
	{
		Random random = new Random();
		
		long inputValue = random.nextLong(); 
			
		long hash = HashUtils.getLongHashedToLong(inputValue);
		System.out.println("input=" + inputValue + "; hash = " + hash);
		
		String hashStr = HashUtils.getLongHashedToString(inputValue);
		
		System.out.println("input=" + inputValue + "; hashStr = " + hashStr);
		
		Assert.assertEquals(hash, Long.parseLong(hashStr));
	}


}
